import cv2 as cv
import numpy as np
def draw_circle(event,x,y,flags,param):#事件event，坐标的x,y，鼠标按哪个键，指针param
     if event ==cv.EVENT_LBUTTONDOWN:#鼠标左键按下
         cv.circle(img,(x,y),100,(255,255,0),2)

img =np.zeros((512,512,3),np.uint8)#创建三通道图像
cv.namedWindow('image')#建立窗口`
#鼠标事件
cv.setMouseCallback('image',draw_circle)#窗口名字，调用的函数名

while True:
    cv.imshow('image',img)
    if cv.waitKey(1) & 0xFF==27:#Esc按下退出
        break
cv.destroyAllWindows()